#{extends 'main.html' /}
#{set title:post.title /}

 <ul id="pagination">
    #{if post.previous()}
        <li id="previous">
            <a href="@{Home.show(post.previous().id)}">
                ${post.previous().title}
            </a>
        </li>
    #{/if}
    #{if post.next()}
        <li id="next">
            <a href="@{Home.show(post.next().id)}">
                ${post.next().title}
            </a>
        </li>
    #{/if}
</ul>
 
#{display post:post, as:'full' /}

<h3>提交评论</h3>
 
#{form @Home.postComment(post.id)}
 
    #{ifErrors}
        <p class="error">
            ${errors[0]}
        </p>
    #{/ifErrors}
 
    <p>
        <label for="author">姓名: </label>
        <input type="text" name="author" id="author" value="${params.author}" />
    </p>
    <p>
        <label for="content">评论: </label>
        <textarea name="content" id="content">${params.content}</textarea>
    </p>
    <p>
        <label for="code">请输入验证码: </label>
        <img src="@{Home.captcha(randomID)}" />
        <br />
        <input type="text" name="code" id="code" size="18" value="" />
        <input type="hidden" name="randomID" value="${randomID}" />
    </p>
    <p>
        <input type="submit" value="确定" />
    </p>
#{/form}

<script type="text/javascript" charset="utf-8">
    $(function() {         
        // Expose the form 
        $('form').click(function() { 
            $('form').expose({api: true}).load(); 
        }); 
        
        // If there is an error, focus to form
        if($('form .error').size()) {
            $('form').expose({api: true, loadSpeed: 0}).load(); 
            $('form input').get(0).focus();
        }
    });
</script>